import axios from '@/libs/axios1';
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' };
let baseUrl = '/scientific/content';
let contentNetns = '/scientific/contentNetns';
let vmCode = '/scientific/vmCode';
// 获取科研内容(申请)
export const queryContentList = (params) => {
    return axios({
        url: `${baseUrl}`,
        method: 'GET',
        params,
        headers: jsonHeaders,
    });
};

//创建科研信息(申请)
export const addContent = (data) => {
    return axios({
        url: `${baseUrl}`,
        method: 'POST',
        data,
        headers: jsonHeaders,
    });
};

//修改科研信息(申请)
export const updateContent = (id, data) => {
    return axios({
        url: `${baseUrl}/${id}`,
        method: 'PUT',
        data,
        headers: jsonHeaders,
    });
};

//查询科研详情
export const getContentDetail = (id) => {
    return axios({
        url: `${baseUrl}/${id}`,
        method: 'GET',
        headers: jsonHeaders,
    });
};

//删除科研信息(申请)
export const delContent = (id) => {
    return axios({
        url: `${baseUrl}/${id}`,
        method: 'DELETE',
        headers: jsonHeaders,
    });
};

//删除科研信息(申请)
export const batchDelContent = (ids) => {
    return axios({
        url: `${baseUrl}/del`,
        method: 'DELETE',
        data:ids,
        headers: jsonHeaders,
    });
};

//审核申请
export const checkContent = (id) => {
    return axios({
        url: `${baseUrl}/check/${id}`,
        method: 'POST',
        headers: jsonHeaders,
    });
};

//归档科研信息
export const archiveContent = (id) => {
    return axios({
        url: `${baseUrl}/archive/${id}`,
        method: 'POST',
        headers: jsonHeaders,
    });
};

//获取编程环境
export const getContentNetns = (id) => {
    return axios({
        url: `${contentNetns}/${id}/code/edit`,
        method: 'POST',
        headers: jsonHeaders,
    });
};
//重新配置编程环境
export const configContentNetns = (id) => {
    return axios({
        url: `${contentNetns}/res/${id}`,
        method: 'POST',
        headers: jsonHeaders,
    });
};

//启用工具库通道
export const startToolTunnel= (projectId,subnetId) => {
    return axios({
        // url: `${contentNetns}/${projectId}/tool/${subnetId}`,
        url: `${contentNetns}/new/${projectId}/tool/${subnetId}`,
        method: 'POST',
        headers: jsonHeaders,
    });
};

//关闭工具库通道
export const stopToolTunnel= (projectId,subnetId) => {
    return axios({
        // url: `${contentNetns}/${projectId}/tool/${subnetId}/stop`,
        url: `${contentNetns}/new/${projectId}/tool/${subnetId}/stop`,
        method: 'POST',
        headers: jsonHeaders,
    });
};

//查看工具库通道详情
export const getToolTunnelDetail = (projectId,subnetId) => {
    return axios({
        // url: `${contentNetns}/${projectId}/tool/${subnetId}/detail`,
        url: `${contentNetns}/new/${projectId}/tool/${subnetId}/detail`,
        method: 'GET',
        headers: jsonHeaders,
    });
};

//获取编程环境绑定的代码库
export const getVmCodes = params => {
    return axios({
        url: `${vmCode}`,
        method: 'GET',
        params,
        headers: jsonHeaders
    });
};

//添加或修改虚拟机代码绑定
export const bindVmCode = data => {
    return axios({
        url: `${vmCode}`,
        method: 'POST',
        data,
        headers: jsonHeaders
    });
};

//重新拉取代码
export const pullVmCode = vmId => {
    return axios({
        url: `${vmCode}/${vmId}`,
        method: 'POST',
        headers: jsonHeaders
    });
};
